<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>js-0511-作业2-螺旋</title>
    <style>
        html{font-family: "Microsoft YaHei";}
        body{margin: 0;}
        .box{
            margin: 10px auto;
            padding-top: 10px;
            width: 660px;
            border: 1px solid #f66;
            box-sizing: border-box;
        }
        .box div{
            display: inline-block;
            margin: 0 0 10px 10px;
            width: 60px;
            height: 35px;
            border: 1px solid #999;
            font-size: 14px;
            line-height: 35px;
            text-align: center;
        }
    </style>
</head>
<body>
    <section class="box"></section>
    <section class="box"></section>
    <section class="box"></section>
    <section class="box"></section>
</body>
<script>
    var oBox = document.getElementsByClassName('box');

    var str = '';
    for(var i=1;i<10;i++){
        for(var j=1;j<10;j++){
            str += `<div>${i}x${j}=${i*j}</div>`;
            if(i === j){
                str += '<br>'
                break;
            };
        };
    };
    oBox[0].innerHTML = str;

    var str = '';
    for(var i=1;i<10;i++){
        for(var j=1;j<10;j++){
            if(i > j){
                continue;
            };
            str += `<div>${i}x${j}=${i*j}</div>`;
            if(i*j === i*9){
                str += '<br>'
                break;
            };
        };
    };
    oBox[1].innerHTML = str;

    var str = '';
    for(var i=9;i>0;i--){
        for(var j=1;j<10;j++){
            str += `<div>${i}x${j}=${i*j}</div>`;
            if(i === j){
                str += '<br>'
                break;
            };
        };
    };
    oBox[2].innerHTML = str;

    var str = '';
    for(var i=9;i>0;i--){
        for(var j=1;j<10;j++){
            if(i > j){
                continue;
            };
            str += `<div>${i}x${j}=${i*j}</div>`;
            if(i*j === i*9){
                str += '<br>'
                break;
            };
        };
    };
    oBox[3].innerHTML = str;
</script>
</html>